{  Statement: http://acmp.ru/?main=task&id_task=336
   Verdict: Accepted
}
uses
    SysUtils, Math;

var
    i,ls,mx,mn,cur:longint;
    s:string;

begin
reset(input, 'input.txt');
rewrite(output, 'output.txt');
readln(s);
ls := length(s);
cur := 0;
mx := 0;
mn := 0;
for i := 1 to ls do begin
    if s[i] = '1' then inc(cur) else dec(cur);
    mx := max(mx, cur);
    mn := min(mn, cur);
end;
write(mx - mn + 1);
end.
